﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SetEmailProperty.aspx.cs"
    Inherits="Main_Utilities_SetEmailProperty" %>

<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../../Styles/accounts.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
    function isNumberKey(control_id, evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 45 || charCode >= 47))
                return false;

            if (charCode == 46) {
                var dotcount = document.getElementById(control_id).value.split('.').length - 1;
                if (dotcount >= 1) {
                    return false;
                }
            }
            return true;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Panel ID="pnlinsert" runat="server">
        <acc:heading ID="pagehead" runat="server" HeadingText="Email Configuration" />
        <div style="margin-left:20%;">
            <table width="70%" class="tablecontent" cellpadding="4">
                <tr>
                    <td colspan="3" class="headtd">
                        Email Info
                    </td>
                </tr>
                <tr>
                    <td colspan="3" align="center">
                        <asp:Label ID="lblmsg" runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width:15%;"></td>
                    <td>Mail User Id<span style="color:Red;">*</span></td>
                    <td><asp:TextBox ID="txtmailuserid" Height="20px" Width="250px" runat="server"></asp:TextBox></td>
                </tr>
                <tr>
                    <td></td>
                    <td>Mail Password<span style="color:Red;">*</span></td>
                    <td><asp:TextBox ID="txtmailpassword" Width="250px" runat="server" 
                           Height="20px" TextMode="Password"></asp:TextBox></td>
                </tr>
                <tr>
                    <td ></td>
                    <td>Mail From<span style="color:Red;">*</span></td>
                    <td><asp:TextBox ID="txtmailfrom" Width="250px" Height="20px" runat="server"></asp:TextBox></td>
                </tr>                
                <tr>
                    <td></td>
                    <td>Mail Display Name<span style="color:Red;">*</span></td>
                    <td><asp:TextBox ID="txtmaildisplayname" Height="20px" Width="250px" runat="server"></asp:TextBox></td>
                </tr>                
                <tr>
                    <td></td>
                    <td>Mail Host<span style="color:Red;">*</span></td>
                    <td><asp:TextBox ID="txtmailhost" Height="20px" Width="250px" runat="server"></asp:TextBox></td>
                </tr>
                <tr>
                    <td></td>
                    <td>Mail Port<span style="color:Red;">*</span></td>
                    <td>
                        <asp:TextBox ID="txtmailport" Height="20px" Width="250px" runat="server" 
                            onKeyPress="return isNumberKey(this.id,event)" MaxLength="3"></asp:TextBox>                        
                    </td>
                </tr>                
                <tr>
                    <td></td>
                    <td colspan="2" align="center">
                        <asp:Button ID="btnSave" CssClass="button" Text="Save" runat="server" onclick="btnSave_Click" OnClientClick="return validation();" />
                        &nbsp;
                        <asp:Button ID="btnCancel" CssClass="button" Text="Cancel" runat="server" onclick="btnCancel_Click" />
                        <script type="text/javascript">
                            function validation() {
                                if (document.getElementById("txtmailuserid").value == '') {
                                    alert("Please Enter the Mail User Id.");
                                    return false;
                                }
                                else if (document.getElementById("txtmailpassword").value == '') {
                                    alert("Please Enter Mail Password.");
                                    return false;
                                }
                                else if (document.getElementById("txtmailfrom").value == '') {
                                    alert("Please Enter Mail from.");
                                    return false;
                                }
                                else if (document.getElementById("txtmaildisplayname").value == '') {
                                    alert("Please Enter Mail Display Name.");
                                    return false;
                                }
                                else if (document.getElementById("txtmailhost").value == '') {
                                    alert("Please Enter Mail Host.");
                                    return false;
                                }
                                else if (document.getElementById("txtmailport").value == '') {
                                    alert("Please Enter Mail Port.");
                                    return false;
                                }
                                else {
                                    return true;
                                }
                            }
                        </script>
                    </td>
                </tr>  
            </table>
        </div>
    </asp:Panel>
    <asp:Panel ID="pnlview" runat="server" Visible="false">
        <acc:heading ID="Heading1" runat="server" HeadingText="Email Configuration View/Edit" />
        <div style="margin-left:5%;">
            <table width="95%">
                <tr>
                    <td class="headtd">Email Details</td>
                </tr>
                <tr>
                    <td style="border:1px solid #818181;">                   
                        <asp:GridView ID="grdview" CssClass="gridview" runat="server" Width="100%" 
                            AutoGenerateColumns="False" DataKeyNames="ID" 
                            onrowcancelingedit="grdview_RowCancelingEdit" onrowediting="grdview_RowEditing" 
                            onrowupdating="grdview_RowUpdating" onrowdeleting="grdview_RowDeleting">
                            <Columns>
                                <asp:TemplateField HeaderText="Sr.No.">
                                    <ItemTemplate>
                                        <%#Container.DataItemIndex + 1 %>
                                    </ItemTemplate>
                                </asp:TemplateField>                                
                                <asp:TemplateField HeaderText="Mail User Id">
                                    <ItemTemplate>                                        
                                        <asp:Label ID="lblMailUserid" runat="server" Text='<%#Bind("MailUserID")%>'></asp:Label>
                                    </ItemTemplate>
                                    <EditItemTemplate>                                        
                                        <asp:TextBox ID="txtMailUserid" Width="145px" runat="server" Text='<%#Bind("MailUserID")%>'></asp:TextBox>
                                    </EditItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Mail From">
                                    <ItemTemplate>                                        
                                        <asp:Label ID="lblMailfrom" runat="server" Text='<%#Bind("MailFrom")%>'></asp:Label>
                                    </ItemTemplate>
                                    <EditItemTemplate>                                        
                                        <asp:TextBox ID="txtMailFrom" Width="145px" runat="server" Text='<%#Bind("MailFrom")%>'></asp:TextBox>
                                    </EditItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Display Name">
                                    <ItemTemplate>                                       
                                        <asp:Label ID="lblMaildisplayName" runat="server" Text='<%#Bind("MailDisplayName")%>'></asp:Label>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:TextBox ID="txtMaildisplayName" Width="145px" runat="server" Text='<%#Bind("MailDisplayName")%>'></asp:TextBox>                                        
                                    </EditItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Mail Host">
                                    <ItemTemplate>                                        
                                        <asp:Label ID="lblMailHost" runat="server" Text='<%#Bind("MailHost")%>'></asp:Label>
                                    </ItemTemplate>
                                    <EditItemTemplate>                                        
                                        <asp:TextBox ID="txtMailHost" Width="145px" runat="server" Text='<%#Bind("MailHost")%>'></asp:TextBox>
                                    </EditItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Mail Port">
                                    <ItemTemplate>                                        
                                        <asp:Label ID="lblMailport" runat="server" Text='<%#Bind("MailPort")%>'></asp:Label>
                                    </ItemTemplate>
                                    <EditItemTemplate>                                        
                                        <asp:TextBox ID="txtMailPort" Width="30px" runat="server" Text='<%#Bind("MailPort")%>'></asp:TextBox>
                                    </EditItemTemplate>
                                </asp:TemplateField>                                                        
                                <asp:TemplateField ShowHeader="False">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lbtnEdit" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit"></asp:LinkButton>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:LinkButton ID="lbtnUpdate" runat="server" CausesValidation="True" CommandName="Update" Text="Update"></asp:LinkButton>
                                        &nbsp;<asp:LinkButton ID="lbtnCancel" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                                    </EditItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField ShowHeader="False">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lbtnDelete" runat="server" CausesValidation="False" OnClientClick="return confirm('Are you sure you want to delete this Record (s)?');" CommandName="Delete" Text="Delete"></asp:LinkButton>                                        
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                    </td>
                </tr>                      
            </table>
        </div>
    </asp:Panel>
    </div>
    </form>
</body>
</html>
